#pragma once
#include "common.h"
#include <unordered_map>
#include <unordered_set>

class PageCache
{
public:
	static PageCache& GetInst();

	Span* NewSpan(size_t pageSize);

	Span* SiteToSpan(void* ptr);

	void RecycleToPageStorage(Span* span);

	~PageCache()
	{

	}

	void release();

public:
	std::mutex _lock;

private:
	SpanList _spanList[NPAGES];
	std::unordered_map<int, Span*> _SiteToSpanHash;
	std::unordered_map<void*, int> _recycle_page_to_system;  //释放申请的内存

	PageCache(){}
	PageCache(const PageCache&) = delete;
	PageCache& operator=(const PageCache&) = delete;

	static PageCache _inst;
};

